home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 9,300 to 9,399 / 9300.zip / AOLDLs / HTML & Web Tools (MAC) / WEB_ WebDocBuilder1.0b1 / WebDocBuilder1.0b1 Folder.sit / WebDocBuilder1.0b1 Folder / WebDocBuilder Text < prev    next >
Text File  |  1995-09-13  |  4KB  |  115 lines

  1. -- Version History
  2. -- 1.0d1 original version
  3. -- 1.0d2 lazy preflight of the convertorScript, to avoid the memory requirements of PhotoFlash when converting
  4. -- files that don╒t contain pictures
  5. -- 1.0d3 name change to WebDocBuilder in preparation for release to net
  6. -- fixed bug that was causing the preflight to be run each time
  7. -- 1.0d4 change to use clip2gif
  8. -- 1.0d5 bug fix, files on the desktop were not being converted properly
  9. -- 1.0d6 bug fix, check for file names being too long
  10. -- 1.0b1 same as 1.0d6, release version
  11.  
  12. script convertorScript
  13.     property have_preflighted : false
  14.     
  15.     on convertPictToGif(doc)
  16.         if not have_preflighted then
  17.             preflight()
  18.         end if
  19.         
  20.         -- gif_convertor        
  21.         tell application "clip2gif"
  22.             save doc as GIF with interlacing
  23.         end tell
  24.     end convertPictToGif
  25.     
  26.     on preflight()
  27.         -- gif_convertor_launch
  28.         launch application "clip2gif"
  29.         set have_preflighted to true
  30.     end preflight
  31. end script
  32.  
  33. on doConvert(doc)
  34.     -- get some salient information about the file from the Finder
  35.     tell application "Finder"
  36.         set doc_parent to (container of doc) as string
  37.         set doc_name to name of doc
  38.     end tell
  39.     -- verify that the file has the .cwk extension
  40.     set name_valid to true
  41.     if length of doc_name < length of ".cwk" then
  42.         set name_valid to false
  43.     end if
  44.     if name_valid then
  45.         if text -1 through -4 of doc_name ¡ ".cwk" then
  46.             set name_valid to false
  47.         end if
  48.     end if
  49.     if name_valid then
  50.         if length of doc_name │ 31 then
  51.             set name_valid to false
  52.         end if
  53.     end if
  54.     if not name_valid then
  55.         display dialog "The document name is either too long or does not have the .cwk extension!" buttons "OK" default button "OK"
  56.         error -128
  57.     end if
  58.     -- get the base name
  59.     set basename to text 1 through -5 of doc_name
  60.     -- convert the basic document to HTML and SimpleText
  61.     tell application "ClarisWorks Office"
  62.         open doc
  63.         save document 1 in file (doc_parent & basename & ".html") using "WWW [HTML]"
  64.         save document 1 in file (doc_parent & basename) using "TeachText & SimpleText"
  65.         close document 1
  66.     end tell
  67.     -- change the file creator of the resulting documents
  68.     -- the text goes to SimpleText, the HTML goes to MacWeb
  69.     -- after that we can ignore it because the SimpleText format already contains the pictures
  70.     tell application "Finder"
  71.         set creator type of alias (doc_parent & basename) to "ttxt" -- text_creator
  72.         set creator type of alias (doc_parent & basename & ".html") to "MWEB" -- web_creator
  73.     end tell
  74.     -- convert each of the pictures from PICT to GIF
  75.     set done to false
  76.     set i to 1
  77.     repeat until done
  78.         tell application "Finder"
  79.             exists item (basename & i & ".pict") in alias doc_parent
  80.         end tell
  81.         if result then
  82.             tell application "Finder"
  83.                 set name of alias (doc_parent & basename & i & ".pict") to (basename & i)
  84.             end tell
  85.             set pict_file to alias (doc_parent & basename & i)
  86.             tell convertorScript to convertPictToGif(pict_file)
  87.             set gif_file to alias ((pict_file as string) & ".gif")
  88.             tell application "Finder"
  89.                 set creator type of gif_file to "JVWR"
  90.                 delete pict_file
  91.             end tell
  92.             set i to i + 1
  93.         else
  94.             set done to true
  95.         end if
  96.     end repeat
  97.     -- all finished!
  98. end doConvert
  99.  
  100. on open doc_list
  101.     launch application "ClarisWorks Office"
  102.     repeat with i in doc_list
  103.         doConvert(i)
  104.     end repeat
  105. end open
  106.  
  107. on run
  108.     if false then
  109.         display dialog "WebDocBuilder" & return & return & ┬
  110.             "⌐1995 Quinn ╥The Eskimo!╙ <quinn@cs.uwa.edu.au>" buttons {"OK"} default button "OK"
  111.     else
  112.         doConvert(alias "SuperGrover:Documents:Web:GreatMoveFAQ.cwk")
  113.     end if
  114. end run
  115.